var app = getApp()
Page({

  data: {
    dataList: [],
    p:0
  },
  onLoad: function (options) {
    this.getList()
  },
  q: function () {
    wx.navigateBack({ changed: true })
  },
  qq: function () {
    wx.switchTab({

      url: '/pages/index/index',

    });
  },
  onReady: function () {
    const vm = this
    vm.setData({
      statusBarHeight: getApp().globalData.statusBarHeight,
      titleBarHeight: getApp().globalData.titleBarHeight
    })

  },
  onReachBottom() {

    this.getList()
  },
  onPullDownRefresh: function () {

    this.setData({
      p: 0
    })
    this.setData({
      dataList: []
    })
    this.getList()
    // wx.stopPullDownRefresh()
  },
  toIndex: function () {
    wx.navigateBack({
      delta: 9
    })
  },
 
  getList: function () {
    wx.showLoading({
      title: '请稍候',
    })
    var that = this
    that.data.p++
    wx.request({
      url: 'https://xiaochengxu.fincoder.com/index.php/Home/Consult/order_show',
      data: {
        myId: app.globalData.myId,
        p: that.data.p,
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        wx.hideLoading()
        console.log(res)
        wx.stopPullDownRefresh()
        if (res.data.status === 1) {
          var tem = that.data.dataList

          for (var i = 0; i < res.data.data.length; i++) {
            // var timeList = res.data.data[i].bespeak_time.split(",");
            // var arr = [];
            // for (var i in timeList) {
            //   arr.push(timeList[i]);

            tem.push(res.data.data[i]);
          }

          that.setData({
            dataList: tem
          })
        }

      }, fail: function () {
        wx.stopPullDownRefresh()
        wx.hideLoading()
      }


    })
  },


})